package week5;

/**
 * Created by Administrator on 2016/3/30.
 */
import java.io.*;
import java.util.Scanner;
public class FileUtil {
    public static String readFile(String name) throws FileNotFoundException{
        StringBuilder text = new StringBuilder();
        Scanner console = null;
        try {
            console = new Scanner(new FileInputStream(name));
            while (console.hasNext()){
                text.append(console.nextLine())
                        .append('\n');
            }
        }finally {
            if (console != null){
                console.close();
            }
        }
        return text.toString();
    }
}

